package net.begincode.blog.controller;

import net.begincode.blog.DemoBiz;
import net.begincode.blog.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("blog/demo/")
public class DemoController {
    private static final Logger LOGGER = LoggerFactory.getLogger(DemoController.class);
    @Resource
    private DemoBiz demoBiz;
    @ResponseBody
    @RequestMapping(value = "allUser", method = RequestMethod.GET)
    public List<User> queryAllUser() {
        LOGGER.info("queryAllUser");
        return demoBiz.queryAll();
    }

    @RequestMapping(value = "index")
    private ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        return modelAndView;
    }
    @RequestMapping(value = "blog")
    private ModelAndView blog(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("blog");
        return modelAndView;
    }
    @RequestMapping(value = "classify")
    private ModelAndView classify(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("classify");
        return modelAndView;
    }
    @RequestMapping(value = "detail")
    private ModelAndView detail(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("detail");
        return modelAndView;
    }
}
